To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

This notebook takes about 20 seconds to run.

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
👀 Reading hidden code
bb = @bind x ClickCounter()
238 ms
👀 Reading hidden code
11.8 μs
missing
👀 Reading hidden code
18.0 μs
👀 Reading hidden code
using HypertextLiteral
: @htl, @htl_str

25.1 ms
ClickCounter (generic function with 2 methods)
👀 Reading hidden code
ClickCounter(text="Click") = @htl("""
<span>
<button>$(text)</button>

<script>

// Select elements relative to `currentScript`
const span = currentScript.parentElement
const button = span.querySelector("button")

// we wrapped the button in a `span` to hide its default behaviour from Pluto

let count = 0

const label = $(text)
const update_button_label = () => {
button.innerText = label + " " + count
}

button.addEventListener("click", (e) => {
count += 1
update_button_label()

// we dispatch the input event on the span, not the button, because
// Pluto's `@bind` mechanism listens for events on the **first element** in the
483 ms